//
//  Type1TableViewCell.m
//  花花时尚
//
//  Created by 王嘉彬 on 15/10/3.
//  Copyright © 2015年 ggs. All rights reserved.
//

#import "Type1TableViewCell.h"
#import "PianKeModel.h"
#import "UIImageView+WebCache.h"
@implementation Type1TableViewCell

- (void)dealloc
{
    [_nameLabel release];
    [_titleLabel release];
    [_image release];
    [_contentLabel release];
    [_likeLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell
{
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:10];
    
    
    self.image = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    
    
    self.contentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.contentLabel];
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont systemFontOfSize:15];
    
    
    self.likeLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.likeLabel];
    self.likeLabel.font = [UIFont systemFontOfSize:10];
}
- (void)layoutSubviews
{
    self.nameLabel.frame = CGRectMake(15, 10, 200, 20);
    self.image.frame = CGRectMake(15, self.nameLabel.frame.size.height + 15, 375 - 30, 375 - 30);
    self.contentLabel.frame = CGRectMake(15, self.nameLabel.frame.size.height + self.image.frame.size.height + self.titleLabel.frame.size.height + 25, self.image.frame.size.width, 100);
    self.titleLabel.frame = CGRectMake(15, self.nameLabel.frame.size.height + self.image.frame.size.height + 20, 200, 30);
    self.likeLabel.frame = CGRectMake(375 - 65, self.nameLabel.frame.size.height + self.image.frame.size.height + self.contentLabel.frame.size.height + 25, 50, 20);
}
- (void)setModel:(PianKeModel *)model
{
    NSString *str = @"";
    str = [str stringByAppendingFormat:@"%@·%@",model.name, model.enname];
    self.nameLabel.text = str;
    
    NSURL *url = [NSURL URLWithString:model.coverimg];
    
    NSLog(@"%@", url);
    [self.image sd_setImageWithURL:url placeholderImage:nil];
    self.contentLabel.text = model.content;
    self.titleLabel.text = model.title;
    self.likeLabel.text = [NSString stringWithFormat:@"%@", model.like];
}
@end
